package com.hequ.merchant.banner;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.hequ.merchant.banner.activity.AddBannerActivity;
import com.hequ.merchant.banner.activity.AddModuleActivity;
import com.hequ.merchant.banner.activity.BannerActivity;
import com.hequ.merchant.banner.activity.BannerListActivity;
import com.hequ.merchant.banner.activity.ModuleListActivity;
import com.hequ.merchant.banner.api.ModuleDataListLoader;
import com.hequ.merchant.banner.util.AppConstant;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button moduleBanenrListBtn;
    private Button addBannerBtn;
    private Button addModuleBtn;
    private Button moduleListBtn;
    private Button upBannerListBtn;
    private Button downBannerListBtn;
    private Button bannerBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        moduleBanenrListBtn = (Button) findViewById(R.id.btn_list);
        addModuleBtn = (Button) findViewById(R.id.btn_moadd);
        moduleListBtn = (Button) findViewById(R.id.btn_molist);
        addBannerBtn = (Button) findViewById(R.id.btn_add);
        upBannerListBtn = (Button) findViewById(R.id.btn_up_list);
        downBannerListBtn = (Button) findViewById(R.id.btn_down_list);
        bannerBtn = (Button) findViewById(R.id.btn_banner);

        moduleBanenrListBtn.setOnClickListener(this);
        addModuleBtn.setOnClickListener(this);
        moduleListBtn.setOnClickListener(this);
        addBannerBtn.setOnClickListener(this);
        upBannerListBtn.setOnClickListener(this);
        downBannerListBtn.setOnClickListener(this);
        bannerBtn.setOnClickListener(this);

        ModuleDataListLoader.getInstance(this).getList();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_molist : {
                ModuleListActivity.setIsModuleManager(true);
                Intent intent = new Intent(this, ModuleListActivity.class);
                startActivity(intent);
                break;
            }
            case R.id.btn_list: {
                ModuleListActivity.setIsModuleManager(false);
                Intent intent = new Intent(this, ModuleListActivity.class);
                startActivity(intent);
                break;
            }

            case R.id.btn_add: {
                AddBannerActivity.isChange = false;
                Intent intent = new Intent(this, AddBannerActivity.class);
                startActivity(intent);
                break;
            }

            case R.id.btn_moadd: {
                AddModuleActivity.isChange = false;
                Intent intent = new Intent(this, AddModuleActivity.class);
                startActivity(intent);
                break;
            }

            case R.id.btn_up_list: {
                Intent intent = new Intent(this, BannerListActivity.class);
                intent.putExtra("code", AppConstant.UPBANNER);
                startActivity(intent);
                break;
            }

            case R.id.btn_down_list: {
                AddModuleActivity.isChange = false;
                Intent intent = new Intent(this, BannerListActivity.class);
                intent.putExtra("code", AppConstant.DOWNBANNER);
                startActivity(intent);
                break;
            }

            case R.id.btn_banner: {
                Intent intent = new Intent(this, BannerActivity.class);
                startActivity(intent);
            }

        }

    }

}
